package com.fi.common.domain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fi.common.domain.IRecognAccessInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.*;

@Data
@TableName("res_accessory_file_info")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResAccessoryFileInfo implements IRecognAccessInfo, Serializable {
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 文件url
     */
    @TableField("file_url")
    private String fileUrl;


    @TableField("md5")
    private String md5;

    /**
     * 状态 1. 未识别 2.已识别 3.已入库,4.异常值 5.残缺值
     */
    @TableField("`status`")
    private Integer status;

    /**
     * 主要类型：1 银行理财  2 结构性存款 3 公募基金 4 券商资管 5 信托计划
     */
    @TableField("main_type")
    private Integer mainType;

    @TableField("title")
    private String title;

    @TableField("subtitle")
    private String subtitle;

    @TableField("info_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date infoTime;

    @TableField("job_id")
    private Integer jobId;

    public void setManager(String manager) {
        if (manager != null && manager.contains(",")) {
            this.manager = manager.split(",")[0];
        } else {
            this.manager = manager;
        }
    }

    @TableField("manager")
    private String manager;

    @TableField("issuer")
    private String issuer;

    @TableField("py_label_type")
    private String pyLabelType;

    @TableField("py_bond_type")
    private String pyBondType;

    @TableField("pushed_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date pushedTime;

    /**
     * 发布时间
     */
    @TableField("issue_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JSONField(format = "yyyy-MM-dd")
    private Date issueTime;

    @TableField("create_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @TableField("data_type")
    private String dataType;

    @TableField("source_url")
    private String sourceUrl;

    @TableField(exist = false)
    private boolean seeError;

    @TableField(value = "product_name")
    private String productName;


    @TableField(value = "sale_code")
    private String saleCode;

    @TableField(value = "product_code")
    private String productCode;

    @TableField(value = "register_code")
    private String registerCode;

    @TableField(exist = false)
    private String tagId;

    @TableField(exist = false)
    private String groupId;

    @TableField("put_status")
    private Integer putStatus;

    @TableField("see_type")
    private Integer seeType;

    @TableField("register_code_status")
    private Integer registerCodeStatus;

    @TableField(exist = false)
    private String sceneId;

    @TableField("match_status")
    private Integer matchStatus;
    /**
     * 命中标签统计
     */
    @TableField(exist = false)
    private Integer hitTagCount;

    @TableField(exist = false)
    private Integer groupCount;

    @TableField(exist = false)
    private Integer groupStatus;

    @TableField(exist = false)
    private Integer flowStatus;

    @TableField(exist = false)
    private Integer changeGroupStatus;

    @TableField(exist = false)
    private String groupName;


    @TableField("manager_type")
    private String managerType;

    @TableField(value = "update_user")
    private String updateUser;

    @TableField(value = "update_time")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @TableField(exist = false)
    private String keyword;

    @TableField("list_url")
    private String listUrl;

    @TableField("file_type")
    private String fileType;

    @TableField("pdf_url")
    private String pdfUrl;

    @TableField("job_manager")
    private String jobManager;

    @TableField("original_title")
    private String originalTitle;

    @TableField("model_match_field")
    private String modelMatchField;

    @TableField("report_period")
    private String reportPeriod;

    @TableField(exist = false)
    private String reportName;

    @TableField(value = "sale_company")
    private String saleCompany;


    @TableField(exist = false)
    private List<String> labelGroupNames;

    @TableField(exist = false)
    private List<String> labelNames;

    @TableField(exist = false)
    private boolean matchedLabel;
    @TableField(exist = false)
    private String putGroupName;
    @TableField(exist = false)
    private String putProductName;
    @TableField(exist = false)
    private String putProductId;
    @TableField(exist = false)
    private String delRemark;
    @TableField(exist = false)
    private String delUser;

    @TableField(exist = false)
    private String delTime;

    @TableField(exist = false)
    private Integer type;


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ResAccessoryFileInfo that = (ResAccessoryFileInfo) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }

    //**************************************************************************************************************
    //******************************************正文 word、excel、html 提取 table 需要的公共 核心字段信息****************
    //**************************************************************************************************************
    @Override
    public Long getRecognAccessId() {
        return id;
    }

    @Override
    public String getRecognAccessName() {
        return title;
    }

    @Override
    public String getRecognAccessManager() {
        return manager;
    }

    @Override
    public String getRecognAccessFileUrl() {
        return fileUrl;
    }

    @Override
    public String getRecognAccessPdfUrl() {
        return pdfUrl;
    }
}
